package com.ftg.learn.rbac.mapper;

import com.ftg.learn.rbac.entity.Role;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Guobt
 * @since 2022-02-09
 */
@Mapper
public interface RoleMapper extends BaseMapper<Role> {


    /**
     * 查某个角色具有的权限
     * @param rid
     * @return
     */
    @Select("select pid from sys_role_permission where rid = #{rid}")
    List<Map<String,Object>> showPermissionForRoleId(@Param("rid") Long rid);


    @Delete("delete from sys_role_permission where rid = #{rid}")
    int delPermissionForRoleId(@Param("rid") Long rid);


    @Insert("insert into sys_role_permission (rid,pid) values(#{rid},#{pid})")
    int savePermissionForRoleId(@Param("rid") Long rid,@Param("pid") Long pid);

}
